<?php
namespace app\m\controller;

use think\Request;
use think\Db;
use think\Cache;
use fast\lucn\Lucn;

/**
 * 首页控制器
 * @author  Lucn30 <Lucn30@126.com>
 */

class Index extends Base {

    protected $model = null;

    public function _initialize()
    {
		define('SIGN', 'index');//定义标识
		$this->assign('controller_sign',SIGN);
		$this->assign('controller_page','首页');
        parent::_initialize();
    }

    public function index() {
	
/*	
	$request = Request::instance();
// 获取当前域名
echo 'domain: ' . $request->domain() . '<br/>';
// 获取当前入口文件
echo 'file: ' . $request->baseFile() . '<br/>';
// 获取当前URL地址 不含域名
echo 'url: ' . $request->url() . '<br/>';
// 获取包含域名的完整URL地址
echo 'url with domain: ' . $request->url(true) . '<br/>';
// 获取当前URL地址 不含QUERY_STRING
echo 'url without query: ' . $request->baseUrl() . '<br/>';
// 获取URL访问的ROOT地址
echo 'root:' . $request->root() . '<br/>';
// 获取URL访问的ROOT地址
echo 'root with domain: ' . $request->root(true) . '<br/>';
// 获取URL地址中的PATH_INFO信息
echo 'pathinfo: ' . $request->pathinfo() . '<br/>';
// 获取URL地址中的PATH_INFO信息 不含后缀
echo 'pathinfo: ' . $request->path() . '<br/>';
// 获取URL地址中的后缀信息
echo 'ext: ' . $request->ext() . '<br/>';
echo '__DIR__: ' . __DIR__ . '<br/>';
echo '__ROOT__: ' . __ROOT__ . '<br/>';
die;
*/

	$this->assign('controller_sign',SIGN);
	$this->assign('method_sign',SIGN);
	
		//banner
		    $table = 'slider';
		    $where['category_id'] = 19;
			$where['status'] = 'normal';
			$banner = Db::name($table)
			->where($where)
			->select();
			$this->assign('slider',$banner);
			//dump($banner);die;
	
		//product
	    	$table = 'product';
			$product = Db::name($table)
			->where('status','normal')
			->order('weigh desc')
			->limit(4)
			->select();
			$this->assign('product',$product);
		
		//about
		$table = 'page';
		$map['id'] = 1;
        $map['status'] = 'normal';
		$about = Db::name($table)
        ->where($map)
        ->find();
		$this->assign('about',$about);
		unset($map);
		
		//article
		$table = 'article';
        $map['status'] = 'normal';
		$article = Db::name($table)
        ->where($map)
        ->order('createtime desc,weigh desc')
		->limit(4)
        ->select();
		$this->assign('article',$article);
		/*
		//ad
		$table = 'ad';
        $map['status'] = 'normal';
		$map['category_id'] = 21;
		$list = Db::name($table)
        ->where($map)
        ->order('createtime desc,weigh desc')
		->limit(10)
        ->select();
		$this->assign('ad',$list);
		*/
		
		$this->assign('title',$this->cache['site']['name'].'【官网】');
		return $this->Fetch('/index');
    }
	
	public function cache() {
		
		
	}
}